//
//  TransferDataThroughScenes.m
//  MessangerSkeleton
//
//  Created by User-23 on 4/24/14.
//  Copyright (c) 2014 IOTrainingCamp. All rights reserved.
//

#import "TransferDataThroughScenes.h"
#import "cocos2d.h"

@interface TransferDataThroughScenes ()

@property (nonatomic, readwrite) BOOL soundsOn;

@end


@implementation TransferDataThroughScenes

static BOOL isInited = NO;

+(id) sharedInstance {
    static TransferDataThroughScenes* instance = nil;
    if (!instance) {
        static dispatch_once_t onceToken;
        dispatch_once(&onceToken, ^{
            instance = [[super alloc] init];
        });
    }
    return instance;
}

- (id)init
{
    if (!isInited) {
        self = [super init];
        if (self) {
            self.soundsOn = YES;
            [self setupAudio];
        }
        isInited = YES;
    }
    return self;
}

+(id) alloc {
    return [TransferDataThroughScenes sharedInstance];
}

-(id) copy {
    return [TransferDataThroughScenes sharedInstance];
}

-(id) mutableCopy {
    return [TransferDataThroughScenes sharedInstance];
}

-(void) switchSoundOnOrOff {
    self.soundsOn = !self.soundsOn;
}

-(void) muteSounds {
    TransferDataThroughScenes* transferedData = [TransferDataThroughScenes sharedInstance];
    if (transferedData.soundsOn) {
        [[OALSimpleAudio sharedInstance] stopEverything];
    }
    else {
        [[OALSimpleAudio sharedInstance] playBg:@"Raycast.m4a" loop:YES];
    }
    [transferedData switchSoundOnOrOff];
}

- (void)setupAudio {
    [[OALSimpleAudio sharedInstance] preloadEffect:@"laser.wav"];//music in event
    [[OALSimpleAudio sharedInstance] preloadBg:@"Raycast.m4a"];//preload background
    //.m4a .wav
}

@end
